package com.test;

import java.util.HashMap;
import java.util.Map;

public class Solution
{
    private static String name;
    public static void main(String[] args)
    {
        System.out.println();
        int[] a = new int[]{2, 7, 11, 15};
        int b = 9;
        int[] c = twoSum(a, b);
        for (int i = 0; i < c.length; i++)
        {
            System.out.println(c[i]);
        }
    }
    private int a(){
        System.out.println(name);
        return 0;
    }

    public static int[] twoSum(int[] nums, int target)
    {
        if (nums.length == 0) return null;
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++)
        {
            map.put(nums[i], i);
        }
        for (int i = 0; i < nums.length; i++)
        {
            int temp = target - nums[i];
            if (map.containsKey(temp) && map.get(temp) != i)
            {
                return new int[]{i, map.get(temp)};
            }
        }
        return null;
    }
}